﻿namespace Test.Console
{
	using System;
	using System.IO;

	using GenericEnum;

	class Program
	{
		static void Main(string[] args)
		{
			// FileMode has not any description so its default string representation will be used.
			Enumeration<FileMode> fileMode = new Enumeration<FileMode>(FileMode.Open);
			System.Console.WriteLine(fileMode);

			// FootballClub members description will be retrieved automatically.
			Enumeration<FootballClub> footballClub = new Enumeration<FootballClub>(FootballClub.MAN_UTD);
			System.Console.WriteLine(footballClub);

			// Initialization of the FileMode description manually.
			Enumeration<FileMode>.Description[FileMode.Open] = "Opens an existing file.";

			// Initialization of the FileMode description manually.
			Enumeration<FileMode>.Description[FileMode.Create] = "Creates a new file.";

			if (fileMode == FileMode.Open)
			{
				// Prints file mode description.
				System.Console.WriteLine(fileMode);
			}

			Enumeration<FileMode> createMode = new Enumeration<FileMode>("Create");
			// Prints file mode description.
			System.Console.WriteLine(createMode);

			try
			{
				Enumeration<FileMode> invalidValue = new Enumeration<FileMode>("CreateRemoteFile");
			}
			catch (ArgumentException ex)
			{
				System.Console.WriteLine(ex.Message);
			}
		}
	}
}
